#pragma once
#include <cstddef>
#include <esp_err.h>

enum SeekMode {
    SeekSet = 0,
    SeekCur = 1,
    SeekEnd = 2
};

class FileInterface {
public:
    virtual esp_err_t open(const char* path, const char* mode) = 0;
    virtual esp_err_t close() = 0;
    virtual esp_err_t write_file(const char* data, size_t size) = 0;
    virtual esp_err_t read_file(char* output, size_t output_size) = 0;
    virtual esp_err_t read_line(int line_num, char* output, size_t output_size) = 0;
    virtual esp_err_t seek(size_t offset, SeekMode mode) = 0;

    // 基类的析构函数必须为虚函数，否则子类中声明的析构函数不会被调用
    virtual ~FileInterface() = default;
};